package tcp;

import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

public class SocketClient {
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            Socket socket = new Socket();
            socket.connect(new java.net.InetSocketAddress("localhost", 8888));
            System.out.print("发送信息：");
            if (scanner.hasNext()){
                String next = scanner.next();
                socket.getOutputStream().write(next.getBytes());
                socket.getOutputStream().close();
            }

        }

    }
}
